home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1130 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.9 KB  |  81 lines

  1. Path: news.internet-eireann.ie!usenet
  2. From: mkelly@vocean.ie
  3. Newsgroups: comp.lang.c++
  4. Subject: Simple DLL Problem
  5. Date: Tue, 09 Jan 1996 14:02:30 GMT
  6. Organization: vocean
  7. Message-ID: <30f27530.80885051@news.internet-eireann.ie>
  8. NNTP-Posting-Host: vocean.internet-eireann.ie
  9. X-Newsreader: Forte Agent .99c/16.141
  10.  
  11. Problem Writing a Simple DLL!
  12.  
  13. Hi,
  14.  
  15. Can anyone tell me where I am going wrong with the following Visual
  16. C++ code?
  17.  
  18. Below is the code for my first DLL written in VC++ 1.5. The code
  19. compiles and a DLL is built, but when it is called from the calling
  20. Visual Basic program, I get the error
  21.     æ Sub or Function not defined æ
  22.  
  23. It would appear that the DLL file is being located, but that the
  24. function is not being recognised.
  25. The DLL code is called from a working VB program and is properly
  26. declared therein as an API function.
  27. I have listed the Compiler and Linker options after the code if that
  28. is of Help.
  29. Thanks
  30.  
  31. Martin
  32.  
  33. ----------------------------------------mySum.h-----------------------------
  34. #include <afxwin.h>
  35.  
  36. #ifdef _cplusplus
  37. extern "C" {  
  38. #endif
  39.  
  40. int FAR PASCAL _export mySum(int a, int b);
  41.  
  42. #ifdef _cplusplus
  43. }
  44. #endif
  45.  
  46.  
  47. ------------------------------- mySum.cpp
  48. ---------------------------------
  49. #include "mysum.h"
  50.  
  51. int    FAR PASCAL _export mySum(int a,int b)
  52. {
  53.     int res; 
  54.     
  55.     res = a + b;
  56.     return res;
  57. }
  58.  
  59.  
  60. ------------------------------ mySum.def
  61. ---------------------------------
  62. LIBRARY   MYSUM
  63. EXETYPE   WINDOWS
  64. CODE      PRELOAD MOVEABLE DISCARDABLE
  65. DATA      PRELOAD MOVEABLE SINGLE
  66. HEAPSIZE  1024
  67. EXPORTS
  68.     WEP  @1 RESIDENTNAME
  69. ----------------------------------------------------------------------------
  70.  
  71. Compiler Options:
  72. /nologo /G2 /W3 /Zi /ALw /Od /D "_DEBUG" /D "_USRDLL" /D "_WINDLL" /D
  73. "_cplusplus" /FR /GD /Fd"MYSUM.PDB"
  74.  
  75. Linker Options:
  76. /NOLOGO /LIB:"lafxdwd" /LIB:"oldnames" /LIB:"libw" /LIB:"ldllcew" /NOD
  77. /NOE /PACKC:61440 /ALIGN:16 /ONERROR:NOEXE /CO /LIB:"commdlg.lib"
  78. /LIB:"olecli.lib" /LIB:"olesvr.lib" /LIB:"shell.lib" /MAP:FULL
  79.  
  80.  
  81.